package com.mall507.fivepeaks.comn.gsonBean;


import java.util.ArrayList;
import java.util.List;

public class ShopMainJsonBeanItemConvert {

    public String result="";
    public Data data;

    public static class Data {
        public String code="";
        public String msg="";
        public List<Item> recommendedGoods;

        public static class Item {
            private String goods_id="";//商品ID后台数据库
            private double goods_price=0.00;//商品价格
            private double store_price=0.00;//店铺价格
            private String path="";//商品图片
            private String goods_name="";//商品名称
            private long goods_salenum=0;//兑换数量
            private double gift_d_coins=0.00;//可报销金额
            private Integer goods_inventory=0;//库存
        }
    }

    public ShopMainJsonBean toShopMainJsonBean(){
        ShopMainJsonBean bean = new ShopMainJsonBean();
        bean.code=this.data.code;
        bean.msg=this.data.msg;
        if("1".equals(this.data.code)){
            bean.data=convertItemInfoList(this.data.recommendedGoods);
        }
        return bean;
    }

    public List<ShopMainJsonBean.ItemInfoListBean> convertItemInfoList(List<Data.Item> modelList){
        List<ShopMainJsonBean.ItemInfoListBean> listInfoList = new ArrayList<ShopMainJsonBean.ItemInfoListBean>();
        for (Data.Item model:modelList){
            ShopMainJsonBean.ItemInfoListBean toModel=new ShopMainJsonBean.ItemInfoListBean();
            toModel.itemType= "shopItem";
            toModel.module="";
            toModel.itemContentList=convertItemContentList(model);
            listInfoList.add(toModel);
        }
        return listInfoList;
    }

    public List<ShopMainJsonBean.ItemInfoListBean.ItemContentListBean> convertItemContentList(Data.Item model){
        List<ShopMainJsonBean.ItemInfoListBean.ItemContentListBean> listContentList = new ArrayList<ShopMainJsonBean.ItemInfoListBean.ItemContentListBean>();
        ShopMainJsonBean.ItemInfoListBean.ItemContentListBean toModel=new ShopMainJsonBean.ItemInfoListBean.ItemContentListBean();
        toModel.picture_url=model.path;//商品图片
        toModel.clickUrl=model.goods_id;//商品详情传入商品ID
        toModel.clickType="6";//点击进入商品详情类型
        toModel.title=model.goods_name;//商品名称
        toModel.titleColor=model.store_price+"";//店铺价格
        toModel.itemSubTitle=model.goods_price+"";//商品价格
        toModel.itemSubscript=model.gift_d_coins+"";//可报销金额
        toModel.itemSubPicture=model.goods_inventory+"";//库存
        toModel.itemBackgroundImageUrl="";
        toModel.itemRecommendedLanguage=model.goods_salenum+"";//兑换数量
        listContentList.add(toModel);
        return listContentList;
    }

}
